package saei.persistencia.DAO;

import java.util.List;

import org.hibernate.Query;

import saei.bean.Software;

@SuppressWarnings("unchecked")
public class SoftwareDAO extends EntidadPersistenteDAO {

	public static Software buscar(String nombre, String version) {
		List<Software> lista = null;
		
		String fromQuery = 	"from Software where nombre = :nombre and " +
							"	version = :version";
		Query query = getSession().createQuery(fromQuery);
		query.setString("nombre", nombre);
		query.setEntity("version", version);
		lista = query.list();
		
		return (Software) (lista != null && lista.size() > 0 ? lista.get(0) : null);
	}
	
	public static List<Software> buscarTodos() {		
		Query query = getSession().createQuery("from Software ");
		
		return query.list();
	}
}
